local tiaoxin = fk.CreateSkill {
  name = "emo_ol_ex_tiaoxin",
  dynamic_desc = function (self, player, lang)
    if player:getMark("emo_ol_ex_tiaoxin_extra-phase") > 0 then
      return "emo_ol_ex_tiaoxin_inner"
    end
  end,
}

Fk:loadTranslationTable {
  ["emo_ol_ex_tiaoxin"] = "挑衅", -- 搬运OL界挑衅
  [":emo_ol_ex_tiaoxin"] = "出牌阶段限一次，你可以选择一名攻击范围内含有你的角色，除非该角色对你使用一张【杀】且你受到此【杀】的伤害，"..
  "否则你弃置其一张牌，然后本阶段本技能限两次。",

  [":emo_ol_ex_tiaoxin_inner"] = "出牌阶段限两次，你可以选择一名攻击范围内含有你的角色，除非该角色对你使用一张【杀】且你受到此【杀】的伤害，否则你弃置其一张牌。",

  ["#emo_ol_ex_tiaoxin"] = "挑衅：令一名角色对你使用一张【杀】且造成伤害，否则你弃置其一张牌",
  ["#emo_ol_ex_tiaoxin-use"] = "挑衅：对 %src 使用一张【杀】，否则其弃置你一张牌",
}

tiaoxin:addEffect("active", {
  anim_type = "control",
  prompt = "#emo_ol_ex_tiaoxin",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(tiaoxin.name, Player.HistoryPhase) < (1 + player:getMark("emo_ol_ex_tiaoxin_extra-phase"))
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select:inMyAttackRange(player)
  end,
  times = function (self, player)
    return 1 + player:getMark("emo_ol_ex_tiaoxin_extra-phase") - player:usedSkillTimes(tiaoxin.name, Player.HistoryPhase)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    if player.general == "emo__liuhuaqiang" then -- 刘华强寻仇耦合
      player:broadcastSkillInvoke("emo__xunchou", math.random(3,4))
    end
    local target = effect.tos[1]
    local use = room:askToUseCard(target, {
      skill_name = tiaoxin.name,
      pattern = "slash",
      prompt = "#emo_ol_ex_tiaoxin-use:"..player.id,
      extra_data = {
        exclusive_targets = {player.id},
        bypass_times = true,
      }
    })
    if use then
      use.extraUse = true
      room:useCard(use)
    end
    if player.dead then return end
    if not (use and use.damageDealt and use.damageDealt[player]) then
      room:setPlayerMark(player, "emo_ol_ex_tiaoxin_extra-phase", 1)
      if not target:isNude() then
        local card = room:askToChooseCard(player, {
          target = target,
          skill_name = tiaoxin.name,
          flag = "he",
        })
        room:throwCard(card, tiaoxin.name, target, player)
      end
    end
  end,
})

return tiaoxin